package com.hrbxlh.util;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
* -------------------------------------------------------
* Copyright (c) 2017, 鑫联华信息科技股份有限公司
* All rights reserved.
* FileName：SessionValues.java
* Description：获取session中村的数据的util类。
* History：
* Date           Author               Desc
* 2017.3.29		  xzx                 建立
* -------------------------------------------------------
*/

public class SessionValues {

	/***@description 获取session中的登录信息
	 * @param 需要获取的key值list 请求对象request
	 * @return Map 通过需要的key获取相应的value
	 * @throws Exception
	 */
	public Map<String, Object> getSessionValues(String[] keysArray, HttpServletRequest request)throws Exception{
		
		Map<String, Object> map = new HashMap<String, Object>();
		try{
			HttpSession session = request.getSession();
			for(int i = 0; i < keysArray.length; i++){
				map.put(keysArray[i], session.getAttribute(keysArray[i]));
			}
		}catch(Exception e){
			throw e;
		}
		return map;
	}
	
}
